package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbefn.
 */
@Configurable
@Entity
@Table(name = "TTLSBEFN",schema = "TLSB")
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsbontPK.class, versionField = "", persistenceUnit="persistenceUnitTLBH", table = "TTLSBEFN", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLBH")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbefn {

	@PersistenceContext(unitName="persistenceUnitTLBH")
    transient EntityManager entityManager;

	@EmbeddedId
    private TtlsbefnPK id;

	public TtlsbefnPK getId() {
        return this.id;
    }

	public void setId(TtlsbefnPK id) {
        this.id = id;
    }

	@Transactional(value="tlbh")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	@Transactional(value="tlbh")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbefn attached = Ttlsbefn.findTtlsbefn(this.id);
            this.entityManager.remove(attached);
        }
    }

	@Transactional(value="tlbh")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	@Transactional(value="tlbh")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	@Transactional(value="tlbh")
    public Ttlsbefn merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbefn merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbefn().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	public static long countTtlsbefns() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbefn o", Long.class).getSingleResult();
    }

	public static List<Ttlsbefn> findAllTtlsbefns() {
        return entityManager().createQuery("SELECT o FROM Ttlsbefn o", Ttlsbefn.class).getResultList();
    }

	public static Ttlsbefn findTtlsbefn(TtlsbefnPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbefn.class, id);
    }

	public static List<Ttlsbefn> findTtlsbefnEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbefn o", Ttlsbefn.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodAplicaci: ").append(getCodAplicaci()).append(", ");
        sb.append("CodVali: ").append(getCodVali()).append(", ");
        sb.append("FecAccfir: ").append(getFecAccfir()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("QnuNumitem: ").append(getQnuNumitem()).append(", ");
        sb.append("QtyTamfich: ").append(getQtyTamfich());
        return sb.toString();
    }

	@Column(name = "QNU_NUMITEM",columnDefinition = "DECIMAL", precision = 12, scale = 0)
    private BigDecimal qnuNumitem;

	@Column(name = "COD_VALI",columnDefinition = "CHAR", length = 5)
    private String codVali;

	@Column(name = "FEC_ACCFIR", columnDefinition = "DATE")
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date fecAccfir;

	@Column(name = "COD_APLICACI",columnDefinition = "CHAR", length = 4)
    private String codAplicaci;

	@Column(name = "QTY_TAMFICH",columnDefinition = "DECIMAL", precision = 12, scale = 0)
    private BigDecimal qtyTamfich;

	@Column(name = "AUD_USUARIO",columnDefinition = "CHAR", length = 8)
    private String audUsuario;

	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	public BigDecimal getQnuNumitem() {
        return this.qnuNumitem;
    }

	public void setQnuNumitem(BigDecimal qnuNumitem) {
        this.qnuNumitem = qnuNumitem;
    }

	public String getCodVali() {
        return this.codVali;
    }

	public void setCodVali(String codVali) {
        this.codVali = codVali;
    }

	public Date getFecAccfir() {
        return this.fecAccfir;
    }

	public void setFecAccfir(Date fecAccfir) {
        this.fecAccfir = fecAccfir;
    }

	public String getCodAplicaci() {
        return this.codAplicaci;
    }

	public void setCodAplicaci(String codAplicaci) {
        this.codAplicaci = codAplicaci;
    }

	public BigDecimal getQtyTamfich() {
        return this.qtyTamfich;
    }

	public void setQtyTamfich(BigDecimal qtyTamfich) {
        this.qtyTamfich = qtyTamfich;
    }

	public String getAudUsuario() {
        return this.audUsuario;
    }

	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	public Date getAudFmodific() {
        return this.audFmodific;
    }

	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }
}
